/*
 *    Copyright (c) 2018-2025, proj All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the proj developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: proj
 */

package com.ykht.proj.coupon.controller.c;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ykht.proj.common.core.util.R;
import com.ykht.proj.coupon.entity.CnBrand;
import com.ykht.proj.coupon.entity.CnShop;
import com.ykht.proj.coupon.service.CnBrandService;
import com.ykht.proj.coupon.vo.PinPaiGuanVo;
import com.ykht.proj.coupon.vo.PpgDetailReq;
import com.ykht.proj.coupon.vo.PpgDetailResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 品牌表
 *
 * @author proj code generator
 * @date 2020-11-16 17:00:21
 */
@RestController
@AllArgsConstructor
@RequestMapping("c/brand")
@Api(value = "cnbrand", tags = "c品牌相关")
public class BrandController {

	private final CnBrandService cnBrandService;

	/**
	 * 分页查询
	 *
	 * @param page    分页对象
	 * @param cnBrand 品牌表
	 * @return
	 */
	@ApiOperation(value = "品牌馆", notes = "品牌馆")
	@GetMapping("/page")
	public R<IPage<PinPaiGuanVo>> page(Page page, CnBrand cnBrand) {
		return R.ok(cnBrandService.opPage(page, cnBrand));
	}

	@ApiOperation(value = "品牌馆详情", notes = "品牌馆详情")
	@PostMapping("/detail")
	public R<PpgDetailResp> ppgDetail(@RequestBody PpgDetailReq req) {
		return R.ok(cnBrandService.ppgDetail(req));
	}


	/**
	 * 根据品牌ID获取品牌信息
	 *
	 * @return R
	 */
	@ApiOperation("根据品牌ID获取品牌信息")
	@PostMapping("/getByBrandId/{brandId}")
	public CnBrand getByBrandId(@PathVariable("brandId") Long brandId) {
		return cnBrandService.getById(brandId);
	}

}
